<!DOCTYPE html>
<html>
<head>
	<title>花礼网登录</title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/styles/head_foot.css">
	<link rel="stylesheet" type="text/css" href="/styles/user.css">
	<script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
	<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<style type="text/css">
		#nav{
			display: none;
		}
	</style>
</head>
<body onload="createCode()">
    <% include header.ejs %>
	<div id="all_content">
		<div class="container">
			<div class="row">
				<div class="col-xs-4 col-xs-offset-2">
					<img src="images/hlbj.png">
				</div>
				<div class="login col-xs-4 pull-right">
					<div id="article_list">
						<ul class="nav nav-tabs" role="tablist">
							<li ><a href="login">登录</a></li>
							<li role="presentation" class="active sign" id="sig"><a href="register" role="tab" data-toggle="tab">注册</a></li>
							
						</ul>
							<div role="tabpanel" class="tab-pane active" id="sign">
								<form action="doregister" method="POST">
									<div class="form-group">
									  <input  type="text"  name="username"  placeholder="请填写您的Email地址" class="pt pt2 pt3">
									</div>
									<div class="form-group">
									  <input type="password"  name="password" placeholder="密码" class="pt pt3">
									</div>
									<div class="form-group">
									  <input type="password"  name="password_again" placeholder="再次输入密码" class="pt pt3">
									</div>
									<div class="form-group">
									  <div class="row">
										  <div class="col-xs-3">
										  	<input type="text"  name="identify" placeholder="验证码" class="pt3 yzm">
										  </div>
										  <div class="col-xs-3">
										  	<input type="text" onclick="createCode()" readonly="readonly" id="checkCode"  class="code" name="codese"/>
										  </div>
										  <div class="col-xs-6">
										  	<a href="" class="pull-right forget">看不清,换一张</a>
										  </div>
									  </div>
									</div>
									<button id="sign_up" type="submit" class="btn btn-warning btn-lg">立即注册</button>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<% include footer.ejs %>
</body>
</html>
<script type="text/javascript">
	$(function(){
		 $("#sign_up").click(function(){
    	$.post("doregister",
    	{
    	username:$("input[name='username']").val(),
    	password:$("input[name='password']").val(),
    	password_again:$("input[name='password_again']").val(),
    	identify:$("input[name='identify']").val(),
    	codese:$("input[name='codese']").val(),
    	},
    function(response,status){
    	if (response=='您输入的验证码不正确') {
    		alert(response);
    		$("input[name='identify']").val("").focus()

    	}else if (response=='两次输入密码不一致') {
    		alert(response); 		
      	}else if (response=='用户名不能为空！') {
      		alert(response);
      	}else{
      		window.location.href="/member/MemberCenter"
      	}
    		})
    		return false;
  		});
	})
</script>


<script language="javascript" type="text/javascript"> 
var codes; 
function createCode() {
  codes = "";
  var codeLength = 6;
  var checkCode = document.getElementById("checkCode");
  var selectChar = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,'o','a','b','c','d','e','f','','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','你','我','他','呵','%','i','k');
  for (var i = 0; i < codeLength; i++) {
    var charIndex = Math.floor(Math.random() * 36);
     codes+= selectChar[charIndex];
  }
    checkCode.value = codes;
}
  
	
</script>